package person.crud.controller;

import java.io.IOException;
import java.sql.SQLException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import person.crud.dao.PersonDAO;
import person.model.Person;

@Controller
@RequestMapping("/get")
public class FindController
{
    @Autowired
    PersonDAO personDAO;

    @RequestMapping("/person")
    public void person(HttpServletResponse response, Person person)
	    throws SQLException, IOException
    {

	for (Person p : personDAO.getCombined(person))
	{
	    response.getWriter().println(p.toString() + ",");

	}

    }

    @RequestMapping("/allpersons")
    public void allPers(HttpServletResponse response) throws IOException
    {
	for (Person p : personDAO.getAll())
	{
	    response.getWriter().println(p.toString() + ",");

	}
    }

}
